#!/bin/bash

# 定义要构建的镜像列表（名称 + 路径）
images=(
  "auth-server:cloud-iaas/auth-server/"
  "gateway-server:cloud-iaas/gateway-server/"
  "manager-service:mall-business/manager-service/"
  "member-service:mall-business/member-service/"
  "product-service:mall-business/product-service/"
  "search-service:mall-business/search-service/"
  "store-service:mall-business/store-service/"
  "message-service:mall-business/message-service/"
  "cart-service:mall-business/cart-service/"
  "order-service:mall-business/order-service/"
)

# 循环处理每个镜像
for item in "${images[@]}"; do
  # 拆分镜像名和路径
  name=${item%%:*}
  path=${item#*:}

  # 删除原有镜像
  docker rmi -f "$name" || true
  # 构建新镜像
  docker build -t "$name" "$path"
done
